package com.sany.test;

import java.io.File;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;

public class CreatDb {
	public static void main(String[] args) throws Exception {
		Session session;
		Configuration conf = new Configuration().configure(
				new File("src/hibernate_creatdb.cfg.xml"));
//				.addClass(Vote.class);
		
		SessionFactory sessionFactory = conf.buildSessionFactory();
		session = sessionFactory.openSession();
		
		Transaction tx = session.beginTransaction();
		SchemaExport dbExport = new SchemaExport(conf);
		dbExport.create(true, true);
		tx.commit();
	}
}
